home *** CD-ROM | disk | FTP | other *** search
- ******************************************************************
- * COPYRIGHT (C) 1986 by Donald Krantz and James Stanley
- * - Note: This is a real, live, actual, registered copyright,
- * and should be treated as such. This source code is from
- * the book "68000 Assembly Language", Krantz and Stanley,
- * Addison-Wesley Publishing Company, Reading, MA, 1986.
- *
- * Permission granted by the authors for non-commercial use
- * in programs released to the public domain, as long as this
- * copyright notice remains attached and visible.
- *
- *****************************************************************
- * CREEP - Does a "spreading dot" trick
- #bit.h
-
- xdef creep
- xref g_pix,image
-
- *****************************************************************
- * CREEP - Fills all "white" space adjacent to pixel (D0.W,D1.W)
- creep:
- movem.w d0-d4,-(a7)
- move.w d0,d2 * save pixel X
- move.w d1,d3 * save pixel Y
- lp1_cp:
- bsr tstpix * check this pixel
- bne sk1_cp * we're done if this one set
- bsr g_pix * set this pixel
- subq.w #1,d0 * move left one pixel
- bra lp1_cp * do it 'til we boink
- sk1_cp:
- addq.w #1,d0 * adjust right end X position
- exg d0,d2 * save leftmost, get original
- addq.w #1,d0 * move left of original
- lp2_cp:
- bsr tstpix * check this pixel
- bne sk2_cp * we're done if this one set
- bsr g_pix * set this pixel
- addq.w #1,d0 * move right one pixel
- bra lp2_cp * keep on to the right end
- sk2_cp:
- subq.w #1,d0 * adjust left end X position
- move.w d0,d4 * save left end X position
-
- move.w d2,d0 * get left end X position
- addq.w #1,d1 * move down to next row
- bsr run * check the run for adjacent pixs
-
- move.w d2,d0 * get right end X limit
- move.w d3,d1 * get original Y
- subq.w #1,d1 * move up one row
- bsr run * check for adjacent white pixels
-
- movem.w (a7)+,d0-d4
- rts
- *****************************************************************
- run:
- bsr tstpix * check this pixel
- bne sk4_cp * set, no need to worry
- bsr creep * set the new line
- sk4_cp:
- addq.w #1,d0 * move right one pixel
- cmp.w d0,d4 * test against right limit
- bge run * loop if more to check
- rts
- *****************************************************************
- * TSTPIX - tests the pixel where D0.W = X and D1.W = Y
- * returns zero flag TRUE if pixel not set
- tstpix:
- movem.l d0/d1/a0,-(a7) * save caller's registers
- ******* See if X and Y are valid addresses *********************
- tst.w d0 * look for off left edge
- bmi sk1_pix * error out if so
- tst.w d1 * look for off top
- bmi sk1_pix * error out if so
- cmp.w #hor_b,d0 * look for off right edge
- bge sk1_pix * error out if so
- cmp.w #vert,d1 * look for off bottom
- bge sk1_pix * error out if so
- ******* pixel (X,Y) is valid; check value of pixel **************
- move.l #image,a0 * get base of image area
- mulu #(hor_w*2),d1 * get vertical offset to line
- add.l d1,a0 * and add to base address
- move.w d0,d1 * save X for later
- lsr.w #3,d0 * get number of bytes to pixel
- add.w d0,a0 * add to pointer
- and.w #$0007,d1 * strip all but bit number
- btst d1,(a0) * test the bit
- bra sk2_pix * and exit
- sk1_pix:
- andi #$FB,ccr * errors always show set pixel
- sk2_pix:
- movem.l (a7)+,d0/d1/a0 * restore caller's registers
- rts
- *****************************************************************
- end